<template>
  <div class="">
    <div class="page-filter mb10 fl">
      <el-form ref="filter" :model="filter" label-width="0">
        <el-form-item class="mr10 mb5 fl">
          <el-input v-model="filter.nickname" placeholder="姓名" size="small" clearable />
        </el-form-item>
        <el-form-item class="mr10 mb5 fl" style="width: 300px">
          <el-button size="small" @click="app.reset('filter')">清 空</el-button>
          <el-button type="primary" size="small" @click="getList">查 询</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-table v-loading="app.loading" class="search-table" :data="list" border fit highlight-current-row style="width: 100%;">
      <el-table-column label="序号" align="center" width="56px">
        <template slot-scope="{$index}">
          {{ $index + 1 }}
        </template>
      </el-table-column>
      <el-table-column label="姓名" width="120px" prop="nickname" />
      <el-table-column label="部门" width="150px" prop="dep_name" />
      <el-table-column label="职位" width="150px" prop="pos_name" />
      <el-table-column label="出差地点" width="180px" prop="addr" />
      <el-table-column label="开始日期" align="center" width="110px" prop="begin_time" />
      <el-table-column label="结束日期" align="center" width="110px" prop="end_time" />
      <el-table-column label="出差区域" align="center" width="110px" prop="region">
        <template slot-scope="{row}">
          <a href="javascript:void(0)" style="color: blue" @click="handleDialog({dTitle: '出差区域', dType: 'add', dField: dField, dRef: 'region'})">{{ row.region }}</a>
        </template>
      </el-table-column>
      <el-table-column label="是否订票" align="center" width="80px" prop="ticket" :formatter="formatter" />
      <el-table-column label="出差事由" min-width="260px" prop="reason" />
      <el-table-column label="申请日期" align="center" width="140px" prop="apply_time" />
      <el-table-column label="备注" min-width="260px" prop="remark" />
    </el-table>
    <pagination v-show="filter.pageAll>0" :total="filter.pageAll" :page.sync="filter.pageCurrent" :limit.sync="filter.pageNumber" @pagination="getList" />
    <Region ref="region" :info="dialog" />
  </div>
</template>

<script>
import { travels } from '@/api/personnel'
import Region from './components/region-dialog'
import page from '@/utils/page'

export default {
  name: '',
  components: { Region },
  extends: page,
  props: {
    reqList: {
      default: travels,
      type: Function
    }
  },
  data() {
    return {
      dField: []
    }
  },
  created() {
    this.getList()
  },
  methods: {
    formatter(e) {
      const ticket = e.ticket
      if (ticket === 0) {
        return '否'
      } else {
        return '是'
      }
    }
  }
}
</script>
